﻿using System.Drawing;
using System.Threading;

namespace Tank90
{
    public class Tank : Role
    {
        private int BlastCount;
        private int BornCount;
        public int BulletX { get; set; }
        public int BulletY { get; set; }
        public Bullet Bullet { get; set; }
        public bool IsBorning { get; set; }
        public bool IsBorned { get; set; }
        public bool IsDying { get; set; }
        public bool IsDied { get; set; }
        public int life { get; set; }
        public int BornTime=0;
        //public Tank()
        //{
        //   MainManager.mainManager.AddGameElement(new Born(this.x,this.y));
        //}
                      
        public virtual void Fire()
        {
        }

        public virtual void GetDirection()
        {
        }

        public void Born(Graphics graphics)
        {
            IsBorning = true;
            if (BornCount < BornImages.Length)
            {
                Thread.Sleep(20);
                graphics.DrawImage(BornImages[BornCount], new Point(x + 5, y + 5));
                BornCount++;
            }
            else
            {
                IsBorned = true;
                IsBorning = false;
            }
        }

        public void Death(Graphics graphics)
        {
            if (BlastCount < BlastImage.Length)
            {
                graphics.DrawImage(BlastImage[BlastCount], new Point(x, y));
                BlastCount++;
            }
        }

        public void BulletDeath()
        {
            Bullet = null;
        }

        protected virtual void SetBullet()
        {
            if (directions == Directions.Up)
            {
                BulletX = x + 15;
                BulletY = y - 5;
            }
            if (directions == Directions.Down)
            {
                BulletX = x + 13;
                BulletY = y + 15;
            }
            if (directions == Directions.Left)
            {
                BulletX = x;
                BulletY = y + 13;
            }
            if (directions == Directions.Right)
            {
                BulletX = x + 20;
                BulletY = y + 15;
            }
        }
    }
}